package com.st.swagger.service;

import com.st.swagger.entity.Carousel;
import com.st.swagger.mapper.CarouselMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;

    public List<Carousel> getAllCarousels() {
        return carouselMapper.findAll();
    }

    public Carousel getCarouselById(Long id) {
        return carouselMapper.findById(id);
    }

    public void createCarousel(Carousel carousel) {
        carouselMapper.insertCarousel(carousel);
    }

    public void updateCarousel(Long id, Carousel carousel) {
        carousel.setId(id);
        carouselMapper.updateCarousel(carousel);
    }

    public void deleteCarousel(Long id) {
        carouselMapper.deleteCarousel(id);
    }
}
